<!DOCTYPE html>
<html>
<head>
    <title>Math Object Random Example 3</title>
    <script type="text/javascript">
    
        function selectFrom(lowerValue, upperValue) {
            var choices = upperValue - lowerValue + 1;
            return Math.floor(Math.random() * choices + lowerValue);
        }
        
        var num = selectFrom(2, 10);
        alert(num);   //number between 2 and 10 (inclusive)
        
        var colors = ["red", "green", "blue", "yellow", "black", "purple", "brown"];
        var color = colors[selectFrom(0, colors.length-1)];
        alert(color);  //any of the strings in the array
        
    </script>
</head>
<body>

</body>
</html>